#!/usr/bin/env bash
# {{ HEADER_AUTOGEN }}
{% if abort_on_error %}# Set propagation of error to exit on first error
set -e
{% endif %}
ROOT="{{ root }}"
{% if compilation_mode == 'separate' %}{% for group in srcs %}
{% if group.file_type == 'verilog' %}{{ vlogan_bin }} -sverilog \
    -full64 \
    {% for tmp_arg in vlog_args %}{{ tmp_arg }} \
    {% endfor %}{% for define in group.defines %}"+define+{{ define.0 | upper }}{% if define.1 %}={{ define.1 }}{% endif %}" \
    {% endfor %}{% for incdir in group.incdirs %}"+incdir+{{ incdir | replace(from=root, to='$ROOT') }}" \
    {% endfor %}{% elif group.file_type == 'vhdl' %}{{ vhdlan_bin }} \
    {% for tmp_arg in vcom_args %}{{ tmp_arg }} \
    {% endfor %}{% endif %}{% for file in group.files %}"{{ file | replace(from=root, to='$ROOT') }}" {% if not loop.last %}\
    {% endif %}{% endfor %}
{% endfor %}
{% else %}{# compilation_mode == 'common' #}{% for file in all_verilog %}{% if loop.first %}{{ vlogan_bin }} -sverilog \
    -full64 \
    {% for tmp_arg in vlog_args %}{{ tmp_arg }} \
    {% endfor %}{% for define in all_defines %}"+define+{{ define.0 | upper }}{% if define.1 %}={{ define.1 }}{% endif %}" \
    {% endfor %}{% for incdir in all_incdirs %}"+incdir+{{ incdir | replace(from=root, to='$ROOT') }}" \
    {% endfor %}{% endif %}"{{ file | replace(from=root, to='$ROOT') }}" {% if not loop.last %}\
    {% endif %}{% if loop.last %}
{% endif %}{% endfor %}
{% for file in all_vhdl %}{% if loop.first %}{{ vhdlan_bin }} \
    {% for tmp_arg in vcom_args %}{{ tmp_arg }} \
    {% endfor %}{% endif %}"{{ file | replace(from=root, to='$ROOT') }}" {% if not loop.last %}\
    {% endif %}{% if loop.last %}
{% endif %}{% endfor %}
{% endif %}
